package com.medusa.aps.business.modules.basic.mp.entity;

import cn.hutool.core.annotation.Alias;
import com.baomidou.mybatisplus.annotation.*;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.model.constant.RegexPool;
import com.medusa.aps.business.model.enums.SourceEnum;
import com.medusa.aps.business.global.model.constant.RegexPools;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Range;

import java.io.Serializable;

/**
 * 客户信息实体类
 *
 * @author yuxh
 * @since 2023-08-14 17:37:43
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TableName(value = "customer_information")
public class CustomerInformation extends BaseEntity<CustomerInformation> {
    /**
     * 主键
     */
    @Schema(description = "主键")
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 客户编码
     */
    @Alias("客户编码")
    @Schema(description = "客户编码")
    @NotBlank(message = "客户编码不能为空")
    @Size(max = 50, message = "客户编码长度不能超过50")
    @Pattern(regexp = RegexPool.ORDER_NO, message = "客户编码只支持数字、字母、符号")
    private String customerCode;

    /**
     * 客户公司名称
     */
    @Alias("客户公司名称")
    @Schema(description = "客户公司名称")
    @NotBlank(message = "客户公司名称不能为空")
    @Size(max = 50, message = "客户公司名称长度不能超过50")
    private String customerCompanyName;

    /**
     * 客户电话
     */
    @Alias("客户电话")
    @Schema(description = "客户电话")
    @NotBlank(message = "客户电话不能为空")
    @Pattern(regexp = RegexPools.MOBILE_TEL, message = "请输入正确的电话号码固话请用-分隔区号")
    @Size(max = 20, message = "客户电话长度不能超过20")
    private String customerPhone;


    /**
     * `
     * 客户姓名
     */
    @Alias("客户姓名")
    @Schema(description = "客户姓名")
    @NotBlank(message = "客户姓名不能为空")
    @Size(max = 50, message = "客户姓名长度不能超过50")
    private String customerName;

    /**
     * 客户优先级
     */
    @Alias("客户优先级")
    @Schema(description = "客户优先级")
    @NotNull(message = "客户优先级不能为空")
    @Range(min = 1, max = 5, message = "客户优先级取值范围为1-5")
    private Integer customerPriority;


    /**
     * 创建人
     */
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    @Schema(description = "创建人")
    private String creator;


    /**
     * 数据来源
     */
    @Schema(description = "数据来源")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private SourceEnum dataSource;

    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }
}

